const express = require('express')
const app = express()

function setTitle(req, res, next) {
    req.body = { name: '自己创建的数据' }
    console.log('setTitle');
    next()
}



app.use(setTitle)

app.get('/', (req, res) => {
    console.log(req.body);
    console.log('01-中间件');
    res.send('01-中间件')
})


app.post('/add', (req, res) => {
    console.log(req.body);
    console.log('post-add');
    res.send('post-add')
})


app.listen(8000, () => { console.log('8000开启成功'); })